package utils

import (
	"fmt"
	"strings"
)

// Join 注意如果是字符串，应该还需要在每个元素加上 ”
func Join[T any](ids []T) string {
	var str_arr = make([]string, len(ids))
	for k, v := range ids {
		str_arr[k] = fmt.Sprintf("%d", v)
	}
	return strings.Join(str_arr, ",")
}

func ConvertInt64ToAny(ids []int64) []interface{} {
	var values []interface{} = make([]interface{}, len(ids))
	//var values []interface{}
	for i, id := range ids {
		values[i] = id
	}
	return values
}

func ConvertToAny[T any](ids []T) []interface{} {
	var values = make([]interface{}, len(ids))
	for i, id := range ids {
		values[i] = id
	}
	return values
}

func IsContain[T int | int8 | int32 | int64 | string](items []T, item T) bool {
	for _, eachItem := range items {
		if eachItem == item {
			return true
		}
	}
	return false
}
